package com.echo.im.server.mq;


import com.echo.im.common.enums.IMCmdType;
import com.echo.im.common.model.platform.IMPlatformCmd;
import com.echo.im.common.model.platform.PlatformCmd;
import com.echo.im.mq.contant.QueueConstants;
import com.echo.im.mq.event.receiver.AbstractMessageReceiver;
import com.echo.im.server.netty.IMServerGroup;
import com.echo.im.server.netty.processor.MessageProcessor;
import com.echo.im.server.netty.processor.factory.ProcessorFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 *
 * @author echo
 * @date 2024-08-13
 */
@Component
@Slf4j
@RequiredArgsConstructor
@DependsOn("IMServerGroup")
public class PlatformCommandMessageReceiver<T extends PlatformCmd> extends AbstractMessageReceiver<IMPlatformCmd<T>> {

    private final ProcessorFactory processorFactory;


    @Override
    public String getQueueName() {
        return QueueConstants.PLATFORM_COMMAND_QUEUE+"."+ IMServerGroup.serverId;
    }

    @Override
    public void doReceive(IMPlatformCmd<T> data) {

        MessageProcessor<IMPlatformCmd<T>> processor = processorFactory.createProcessor(IMCmdType.PLATFORM_COMMAND_MESSAGE);

        processor.process(data);
    }



}
